IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spTfiles_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spTfiles_RetrieveAll'
		DROP  Procedure  spTfiles_RetrieveAll
	END

GO

PRINT 'Creating Procedure spTfiles_RetrieveAll'
GO

CREATE Procedure spTfiles_RetrieveAll
	(
		@FILENO char(20) = null, 
		@ILPNO char(20) = null, 
		@NBSNO char(20) = null, 
		@FTYPE char(20) = null, 
		@LOCNO char(10) = null, 
		@FSTATUS char(10) = null, 
		@FUSER char(8) = null, 
		@FEMPNO char(10) = null, 
		@FDATETIME DateTime = null, 
		@FTRANDTL char(80) = null, 
		@FCREATED DateTime = null, 
		@FCREATEDBY char(8) = null, 
		@FNOTES text = null, 
		@FHOLD56 numeric = null, 
		@FNOBD numeric = null, 
		@FNOTD numeric = null, 
		@FLBLPRT numeric = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 9/6/2007	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	Tfiles
	
	WHERE	(@FILENO IS NULL OR Tfiles.FILENO = @FILENO)
	  AND	(@ILPNO IS NULL OR Tfiles.ILPNO = @ILPNO)
	  AND	(@NBSNO IS NULL OR Tfiles.NBSNO = @NBSNO)
	  AND	(@FTYPE IS NULL OR Tfiles.FTYPE = @FTYPE)
	  AND	(@LOCNO IS NULL OR Tfiles.LOCNO = @LOCNO)
	  AND	(@FSTATUS IS NULL OR Tfiles.FSTATUS = @FSTATUS)
	  AND	(@FUSER IS NULL OR Tfiles.FUSER = @FUSER)
	  AND	(@FEMPNO IS NULL OR Tfiles.FEMPNO = @FEMPNO)
	  AND	(@FDATETIME IS NULL OR Tfiles.FDATETIME = @FDATETIME)
	  AND	(@FTRANDTL IS NULL OR Tfiles.FTRANDTL = @FTRANDTL)
	  AND	(@FCREATED IS NULL OR Tfiles.FCREATED = @FCREATED)
	  AND	(@FCREATEDBY IS NULL OR Tfiles.FCREATEDBY = @FCREATEDBY)
	  AND	(@FHOLD56 IS NULL OR Tfiles.FHOLD56 = @FHOLD56)
	  AND	(@FNOBD IS NULL OR Tfiles.FNOBD = @FNOBD)
	  AND	(@FNOTD IS NULL OR Tfiles.FNOTD = @FNOTD)
	  AND	(@FLBLPRT IS NULL OR Tfiles.FLBLPRT = @FLBLPRT)

	-- Return to calling method
	RETURN
GO
